package com.bawei.park2211a.adapter

import android.graphics.Color
import android.widget.TextView
import androidx.core.view.ContentInfoCompat
import androidx.core.view.isVisible
import com.bawei.base.bean.CarEntity
import com.bawei.base.mvvm.BaseViewModel
import com.bawei.park2211a.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import org.w3c.dom.Text

class CarAdapter:BaseQuickAdapter<CarEntity,BaseViewHolder>(R.layout.item_car) {
    override fun convert(helper: BaseViewHolder, item: CarEntity) {
        helper.setText(R.id.car_id,item.spaceNumber)
        helper.setText(R.id.car_type,item.spaceType)
        helper.setText(R.id.car_area,item.areaName)
        helper.setText(R.id.car_state,item.spaceStatus)
        val car_number = helper.getView<TextView>(R.id.car_number)
        val car_user = helper.getView<TextView>(R.id.car_number)
        val car_state = helper.getView<TextView>(R.id.car_state)

        when(item.spaceStatus){
            "空闲"->{
                car_number.isVisible=false
                car_user.isVisible=false
                car_state.setBackgroundResource(R.drawable.text_color1)
                car_state.setTextColor(Color.GREEN)

            }
            "已占用"->{
                car_number.isVisible=true
                car_user.isVisible=true
                helper.setText(R.id.car_user,item.userName)
                helper.setText(R.id.car_number,item.licensePlate)
                car_state.setBackgroundResource(R.drawable.text_color2)
                car_state.setTextColor(Color.BLUE)
            }
            "维护中"->{
                car_number.isVisible=false
                car_user.isVisible=false
                car_state.setBackgroundResource(R.drawable.text_color3)
                car_state.setTextColor(Color.YELLOW)
            }
        }
    }
}